package com.shinewind.info.controller;

import cn.hutool.core.util.BooleanUtil;
import com.shinewind.common.constant.messageConstant;
import com.shinewind.info.service.IUserRoleService;
import com.shinewind.info.service.IUserInfoService;
import com.shinewind.pojo.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
@Api(value = "用户身份接口",description = "用于展示用户身份信息")
public class UserController {
    @Autowired
    private IUserInfoService iUserInfoService;
    @Autowired
    private IUserRoleService iUserRoleService;

    @GetMapping("/role/{uId}")
    @ApiOperation(value = "用户身份信息",notes = "用户身份信息",response = Result.class)
    public Result getUserRoleByuId(@PathVariable("uId") String uId){
        List<String> rolesList = iUserRoleService.getUserRoleByuId(uId);
        return Result.success(rolesList, BooleanUtil.isTrue(rolesList.size() > 0),
                messageConstant.QUERY_SUCCESS);
    }
}